import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, Index } from 'typeorm';
import { UserTitleCertification, UserType } from "common/utils/data";

@Entity('USER', {
  synchronize: false,
}) // 用户
export class UserModel extends BaseModel {
  @Column({
    comment: '昵称',
    type: 'varchar',
    length: 50,
  })
  @Index('USER.name', {
    unique: true,
  })
  name: string;

  @Column({
    comment: '手机号',
    type: 'varchar',
    length: 50,
  })
  @Index('USER.mobile', {
    unique: true,
  })
  mobile: string;

  @Column({
    comment: '密码',
    type: 'varchar',
    length: 250,
    select: false,
  })
  password: string;

  @Column({
    comment: '第三方微信登录openid',
    type: 'varchar',
    length: 250,
    default: '',
    select: false,
  })
  wxId: string;

  @Column({
    comment: '用户类型（""：普通，ADMIN：管理员）',
    type: 'varchar',
    length: 50,
    default: UserType.NORMAL,
  })
  userType: UserType;

  @Column({
    comment: '状态（1：启用，0：禁用）',
    type: 'smallint',
    default: 1,
  })
  status: number;

  @Column({
    comment: '头像url',
    type: 'varchar',
    default: '',
  })
  avatar: string;

  @Column({
    comment: '头衔',
    type: 'varchar',
    default: '',
  })
  title: string;

  @Column({
    comment: '头衔认证（""：普通，V：普通认证，HIGH_V：高级认证）',
    type: 'varchar',
    length: 50,
    default: UserTitleCertification.NORMAL,
  })
  titleCertification: UserTitleCertification;

  @Column({
    comment: '个性签名',
    type: 'varchar',
    default: '',
  })
  signature: string;
}
